app.controller("ListInfo", function($scope, $rootScope, $http, $route, $location, $compile) {
	//初始值
	$scope.bb = $location.search().classId;
	$scope.classify =$scope.bb|| $rootScope.Cookie;
	$scope.bgColor = {
		nvzhuang: "rgb(243,48,154)",
		jiaju: "rgb(22,133,241)",
		huangjin: "rgb(254,189,3)",
		shouji: "rgb(12,133,218)",
		nanzhuang: "rgb(1,174,220)",
		liansuochaoshi: "rgb(8,188,1)",
		tongzhuang: "rgb(242,58,58)",
		shipin: "rgb(247,63,142)",
		jiadian: "rgb(218,39,131)",
		neiyi: "rgb(217,39,130)",
		mingbiao: "rgb(31,185,175)",
		huazhuang: "rgb(248,56,139)",
		canting: "rgb(20,126,231)",
		gongyi: "rgb(152,43,217)",
		yunying: "rgb(28,191,191)"
	};

	$http({
		//使用JSON格式
		url: "php/ListInfo.json",
		method: "GET",
		dataType:"json"
	}).then(function(res){
		console.log(res.data);
		$scope.preLoad(res.data);
		$scope.nvList = res.data;
	});
	//预加载处理
	$scope.preLoad = function(obj){
		var arrImg = [];
		for(var i = 0; i < obj.length; i++) {
			var aImg = new Image;
			var n = 0;
			aImg.onload = function() {
				n++;
				if(n==arrImg.length){
				$scope.nvList =arrImg;
				$('.container').BlocksIt({
						numOfCol: 5,
						offsetX: 7,
						offsetY: 7,
						blockElement: '.grid'
				});
			}
			}
			aImg.src = obj[i].src;
			arrImg.push(obj[i]);
		}
	}
	var currentWidth = 1100;
	$(window).resize(function() {
		var winWidth = $(window).width();
		var conWidth;
		if(winWidth < 660) {
			conWidth = 440;
			col = 2
		} else if(winWidth < 880) {
			conWidth = 660;
			col = 3
		} else if(winWidth < 1100) {
			conWidth = 880;
			col = 4;
		} else {
			conWidth = 1100;
			col = 5;
		}
		if(conWidth != currentWidth) {
			currentWidth = conWidth;
			$('.container').width(conWidth);
			$('.container').BlocksIt({
				numOfCol: col,
				offsetX: 7,
				offsetY: 7,
				blockElement: '.grid'
			});
		}
});

});